<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Connector_mdl extends CI_Model{

	const DB_CONNECTOR = 'connector';

	function __construct()
	{
		parent::__construct();
	}

	function get_bind_vendor_by_uid( $uid )
	{
		$this->db->select('vendor');
		return $this->db->where('user_id',$uid)->get(self::DB_CONNECTOR)->result();
	}

	function get_bind_connector_by_uid( $uid )
	{
		return $this->db->where('user_id',$uid)->get(self::DB_CONNECTOR)->result();
	}

	function get_bind_by_vendor_and_suid( $vendor, $suid )
	{
		$array = array('social_userid' => $suid, 'vendor' => $vendor);
		return $this->db->where($array)->get(self::DB_CONNECTOR)->row();
	}

	function add_connector($data)
	{
		$this->db->insert(self::DB_CONNECTOR,$data);
	}

	function edit_connector($cid,$data)
	{
		$this->db->where('connect_id',$cid)->update(self::DB_CONNECTOR,$data);
	}

	function del_connector($cid)
	{
		$this->db->where('connect_id',$cid)->delete(self::DB_CONNECTOR);
	}

	function del_connector_by_vendor_uid($vendor,$uid)
	{
		$array = array('user_id' => $uid, 'vendor' => $vendor);
		$this->db->where($array)->delete(self::DB_CONNECTOR);
	}

}